﻿using OpenApi.OAuths;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace OpenApiConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            OAuthBase oauthBase = new OAuthBase();
            Uri uri = new Uri("http://127.0.0.1:10088/LotteryDraw/Latest?page=1&size=10");

            string method = "GET";
            string consumerKey = "d0f89841d14d19cf94a619a12d3d51f9";
            string consumerSecret = "6e0da7e0a81f1392e1a893a5619ae813";
            string token = null;
            string tokenSecret = null;
            string timeStamp = oauthBase.GenerateTimeStamp();
            string nonce = oauthBase.GenerateNonce();
            OAuthBase.SignatureTypes signatureType = OAuthBase.SignatureTypes.HMACSHA1;
            string normalizedUrl = null;
            string normalizedRequestParameters = null;
            var signature = oauthBase.GenerateSignature(uri, consumerKey, consumerSecret, token, tokenSecret, method, timeStamp, nonce, signatureType, out normalizedUrl, out normalizedRequestParameters);

            uri = new Uri(normalizedUrl + "?" + normalizedRequestParameters + "&" + OAuthBase.OAuthSignatureKey + "=" + signature);
            WebClient wc = new WebClient();
            Console.WriteLine(wc.DownloadString(uri));
            Console.Read();
        }
    }
}
